import tkinter as tk
import random

class GuessNumberGame:
    def __init__(self, master):
        self.master = master
        self.master.title("Угадай число")
        
        self.secret_number = random.randint(1, 128)

        self.label = tk.Label(master, text="Введите число от 1 до 128:")
        self.label.pack()

        self.entry = tk.Entry(master)
        self.entry.pack()

        self.button = tk.Button(master, text="Проверить", command=self.check_number)
        self.button.pack()

        self.result_text = tk.StringVar()
        self.result_label = tk.Label(master, textvariable=self.result_text)
        self.result_label.pack()

    def check_number(self):
        user_guess = int(self.entry.get())
        if user_guess < self.secret_number:
            self.result_text.set("Загаданное число больше")
        elif user_guess > self.secret_number:
            self.result_text.set("Загаданное число меньше")
        else:
            self.result_text.set("Вы угадали!")

if __name__ == "__main__":
    root = tk.Tk()
    game = GuessNumberGame(root)
    root.mainloop()